<#import "/admin/_layer.html" as layout>
<@layout.header ""></@layout.header>
<@layout.body>
<div class="col-12" style="padding: 0 20px">
    <div class="row">
        <div class="col-7" style="background: #ffffff" id="image-box">
            <div class="row">
                <img src="/static/${file.filePath!}" style="width: 100%">
            </div>
        </div>

        <div class="col-5" style="background: #efefef" id="image-info">
            <div class="form-group">
                <label class="col-sm-5 control-label">文件名</label>
                <input class="form-control" readonly value="${file.fileName!}"></input>
            </div>
            <div class="form-group">
                <label>URL</label>
                <textarea class="form-control" rows="2" readonly>${file.filePath!}</textarea>
            </div>
            <div class="form-group">
                <label>文件大小</label>
                <input class="form-control" rows="2" readonly value="${file.fileSize!}"></input>
            </div>
            <div class="form-group">
                <label class="col-sm-5 control-label">上传于</label>
                <input class="form-control" readonly value="<@formatTime value=file.created!/>"></input>
            </div>
            <div class="col-3" style="padding: 20px">
                <a href="javascript:;" class="btn btn-block btn-danger" onclick="del(${file.id!})">彻底删除</a>
            </div>
        </div>
    </div>
</div>
</@layout.body>
<@layout.script>
    <script>

        $(document).ready(function () {
            var height = $(document).height();
            $("#image-box").css("height", height + "px");
            $("#image-box").css("min-height", height + "px");
            $("#image-info").css("height", height + "px");
            $("#image-info").css("min-height", height + "px");
            $("img").css("max-height", height + "px");
        });

        function del(id) {
            layer.confirm('确定要删除附件吗?', {
                btn : ['确定', '取消']
            }, function(i) {
                layer.close(i);
                ajaxPost("/admin/attachment/doDelete", {id: id}, function () {
                    alertSuccess("删除成功", function(){
                        parent.layer.data.needReload = true;
                        parent.layer.closeAll();
                        parent.location.reload();
                    })
                })
            });
        }

    </script>
</@layout.script>